#基类Base
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Base():

    #初始化方法
    def __init__(self,driver):
        self.driver = driver
    #浏览器方法
    def open_url(self,url):
        self.driver.get(url)
    #封装定位方法
    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,20,0.5).until(
                lambda driver: self.driver.find_element(*loc).is_displayed
            )
            return self.driver.find_element(*loc)
        except Exception as e:
            print(e)
    #点击事件
    def click(self,loc):
        self.find_element(loc).click()
    #键盘输入事件
    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)
    #文本事件
    def text(self,loc):
        self.find_element(loc).text()
    #清空事件
    def clear(self,loc):
        self.find_element(loc).clear()